home *** CD-ROM | disk | FTP | other *** search
- /* Macintosh specific extensions */
-
- /* This file is intended to be used for the addition of Scheme procedures */
- /* to access machine specific features (such as Toolbox routines). */
-
- #include "os.h"
- #include "mem.h"
-
- #include "os_mac.h"
-
- #include "os_mac_Help.h"
-
- /*---------------------------------------------------------------------------*/
-
- void pascal_str( str, pstr ) /* utility to convert to Pascal string */
- SCM_obj str;
- Str255 pstr;
- { long i, len = SCM_length( str );
- if (len > 255) len = 255; /* truncate if too long */
- pstr[0] = len;
- for (i=0; i<len; i++) pstr[i+1] = SCM_obj_to_str(str)[i];
- }
-
- /*---------------------------------------------------------------------------*/
-
-
- SCM_obj mac_X23newwindow( bounds, title, visible, procid, behind, goaway ) /* simplified version of NewWindow */
- SCM_obj bounds, title, visible, procid, behind, goaway;
- { WindowPtr w;
- Str255 ptitle;
- pascal_str( title, ptitle );
- w = NewWindow( NULL, SCM_obj_to_str(bounds), ptitle,
- (visible!=SCM_false), (int)SCM_obj_to_int(procid),
- (WindowPtr)SCM_obj_to_int(behind), (goaway!=SCM_false), 0L );
- return (long)SCM_int_to_obj((long)w);
- /* Note: The pointer to the window is returned as a fixnum. This should */
- /* be fine assuming the Mac returns a pointer with the upper 4 bits of */
- /* the pointer at 0. This is a reasonnable assumtion but it might cause */
- /* problems if the MacOS starts using high memory. */
- }
-
- SCM_obj mac_X23getnewwindow( windowid, behind ) /* simplified version of GetNewWindow */
- SCM_obj windowid, behind;
- { WindowPtr w;
- w = GetNewWindow( (int)SCM_obj_to_int(windowid), NULL, (WindowPtr)SCM_obj_to_int(behind) );
- return (long)SCM_int_to_obj((long)w);
- }
-
- SCM_obj mac_X23disposewindow( w ) /* window pointer is a fixnum */
- SCM_obj w;
- { DisposeWindow( (WindowPtr)SCM_obj_to_int(w) ); return (long)SCM_false; }
-
- SCM_obj mac_X23setwtitle( w, title )
- SCM_obj w, title;
- { Str255 ptitle;
- pascal_str( title, ptitle );
- SetWTitle( (WindowPtr)SCM_obj_to_int(w), ptitle );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23selectwindow( w )
- SCM_obj w;
- { SelectWindow( (WindowPtr)SCM_obj_to_int(w) ); return (long)SCM_false; }
-
- SCM_obj mac_X23hidewindow( w )
- SCM_obj w;
- { HideWindow( (WindowPtr)SCM_obj_to_int(w) ); return (long)SCM_false; }
-
- SCM_obj mac_X23showwindow( w )
- SCM_obj w;
- { ShowWindow( (WindowPtr)SCM_obj_to_int(w) ); return (long)SCM_false; }
-
- SCM_obj mac_X23frontwindow()
- { return (long)SCM_int_to_obj((long)FrontWindow()); }
-
- SCM_obj mac_X23findwindow( p, w_cell ) /* w_cell is a cons cell to hold window pointer */
- SCM_obj p, w_cell;
- { Point pt = *(Point *)SCM_obj_to_str(p);
- WindowPtr w;
- int res = FindWindow( pt, &w );
- *(SCM_obj *)(w_cell-SCM_type_PAIR+PAIR_CAR*sizeof(SCM_obj)) = (long)SCM_int_to_obj((long)w);
- return (long)SCM_int_to_obj((long)res);
- }
-
- SCM_obj mac_X23trackgoaway( w, p )
- SCM_obj w, p;
- { Point pt = *(Point *)SCM_obj_to_str(p);
- if (TrackGoAway( (WindowPtr)SCM_obj_to_int(w), pt )) return (long)SCM_true; else return (long)SCM_false;
- }
-
- SCM_obj mac_X23dragwindow( w, p, r )
- SCM_obj w, p, r;
- { Point pt = *(Point *)SCM_obj_to_str(p);
- DragWindow( (WindowPtr)SCM_obj_to_int(w), pt, SCM_obj_to_str(r) );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23invalrect( port, r )
- SCM_obj port, r;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- InvalRect( SCM_obj_to_str(r) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23beginupdate( w )
- SCM_obj w;
- { BeginUpdate( (WindowPtr)SCM_obj_to_int(w) ); return (long)SCM_false; }
-
- SCM_obj mac_X23endupdate( w )
- SCM_obj w;
- { EndUpdate( (WindowPtr)SCM_obj_to_int(w) ); return (long)SCM_false; }
-
- /*---------------------------------------------------------------------------*/
-
- SCM_obj mac_X23openport( port )
- SCM_obj port;
- { GrafPtr save; GetPort( &save );
- OpenPort( (GrafPtr)SCM_obj_to_int(port) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23initport( port )
- SCM_obj port;
- { GrafPtr save; GetPort( &save );
- InitPort( (GrafPtr)SCM_obj_to_int(port) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23closeport( port )
- SCM_obj port;
- { ClosePort( (GrafPtr)SCM_obj_to_int(port) ); return (long)SCM_false; }
-
- SCM_obj mac_X23setport( port )
- SCM_obj port;
- { SetPort( (GrafPtr)SCM_obj_to_int(port) ); return (long)SCM_false; }
-
- SCM_obj mac_X23getport()
- { GrafPtr port; GetPort( &port ); return (long)SCM_int_to_obj((long)port); }
-
- SCM_obj mac_X23setorigin( port, h, v )
- SCM_obj port, h, v;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- SetOrigin( (int)SCM_obj_to_int(h), (int)SCM_obj_to_int(v) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23backpat( port, pat )
- SCM_obj port, pat;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- BackPat( SCM_obj_to_str(pat) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23hidecursor()
- { HideCursor(); return (long)SCM_false; }
-
- SCM_obj mac_X23showcursor()
- { ShowCursor(); return (long)SCM_false; }
-
- SCM_obj mac_X23pensize( port, width, height )
- SCM_obj port, width, height;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- PenSize( (int)SCM_obj_to_int(width), (int)SCM_obj_to_int(height) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23penmode( port, mode )
- SCM_obj port, mode;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- PenMode( (int)SCM_obj_to_int(mode) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23penpat( port, pat )
- SCM_obj port, pat;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- PenPat( SCM_obj_to_str(pat) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23pennormal( port )
- SCM_obj port;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- PenNormal();
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23moveto( port, h, v )
- SCM_obj port, h, v;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- MoveTo( (int)SCM_obj_to_int(h), (int)SCM_obj_to_int(v) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23move( port, dh, dv )
- SCM_obj port, dh, dv;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- Move( (int)SCM_obj_to_int(dh), (int)SCM_obj_to_int(dv) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23lineto( port, h, v )
- SCM_obj port, h, v;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- LineTo( (int)SCM_obj_to_int(h), (int)SCM_obj_to_int(v) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23line( port, dh, dv )
- SCM_obj port, dh, dv;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- Line( (int)SCM_obj_to_int(dh), (int)SCM_obj_to_int(dv) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23textfont( port, font )
- SCM_obj port, font;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- TextFont( (int)SCM_obj_to_int(font) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23textface( port, face )
- SCM_obj port, face;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- TextFace( (int)SCM_obj_to_int(face) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23textmode( port, mode )
- SCM_obj port, mode;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- TextMode( (int)SCM_obj_to_int(mode) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23textsize( port, size )
- SCM_obj port, size;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- TextSize( (int)SCM_obj_to_int(size) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23spaceextra( port, extra )
- SCM_obj port, extra;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- SpaceExtra( (int)SCM_obj_to_int(extra) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23drawchar( port, ch ) /* ch is a Scheme character (a fixnum will also do!) */
- SCM_obj port, ch;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- DrawChar( (char)SCM_obj_to_int(ch) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23drawstring( port, s ) /* s is a Scheme string */
- SCM_obj port, s;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- DrawText( SCM_obj_to_str(s), 0, SCM_length(s) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23drawtext( port, textBuf, firstByte, byteCount ) /* textBuf is a Scheme string */
- SCM_obj port, textBuf, firstByte, byteCount;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- DrawText( SCM_obj_to_str(textBuf), (int)SCM_obj_to_int(firstByte), (int)SCM_obj_to_int(byteCount) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23charwidth( port, ch ) /* ch is a Scheme character (a fixnum will also do!) */
- SCM_obj port, ch;
- { long width;
- GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- width = CharWidth( (char)SCM_obj_to_int(ch) );
- SetPort( save );
- return SCM_int_to_obj( width );
- }
-
- SCM_obj mac_X23stringwidth( port, s ) /* s is a Scheme string */
- SCM_obj port, s;
- { long width;
- GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- width = TextWidth( SCM_obj_to_str(s), 0, SCM_length(s) );
- SetPort( save );
- return SCM_int_to_obj( width );
- }
-
- SCM_obj mac_X23textwidth( port, textBuf, firstByte, byteCount ) /* textBuf is a Scheme string */
- SCM_obj port, textBuf, firstByte, byteCount;
- { long width;
- GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- width = TextWidth( SCM_obj_to_str(textBuf), (int)SCM_obj_to_int(firstByte), (int)SCM_obj_to_int(byteCount) );
- SetPort( save );
- return SCM_int_to_obj( width );
- }
-
- SCM_obj mac_X23localtoglobal( port, pt )
- SCM_obj port, pt;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- LocalToGlobal( SCM_obj_to_str(pt) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23globaltolocal( port, pt )
- SCM_obj port, pt;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- GlobalToLocal( SCM_obj_to_str(pt) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23framerect( port, r )
- SCM_obj port, r;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- FrameRect( SCM_obj_to_str(r) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23paintrect( port, r )
- SCM_obj port, r;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- PaintRect( SCM_obj_to_str(r) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23eraserect( port, r )
- SCM_obj port, r;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- EraseRect( SCM_obj_to_str(r) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23invertrect( port, r )
- SCM_obj port, r;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- InvertRect( SCM_obj_to_str(r) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23fillrect( port, r, pat )
- SCM_obj port, r, pat;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- FillRect( SCM_obj_to_str(r), SCM_obj_to_str(pat) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23frameroundrect( port, r, ovWd, ovHt )
- SCM_obj port, r, ovWd, ovHt;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- FrameRoundRect( SCM_obj_to_str(r), (int)SCM_obj_to_int(ovWd), (int)SCM_obj_to_int(ovHt) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23paintroundrect( port, r, ovWd, ovHt )
- SCM_obj port, r, ovWd, ovHt;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- PaintRoundRect( SCM_obj_to_str(r), (int)SCM_obj_to_int(ovWd), (int)SCM_obj_to_int(ovHt) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23eraseroundrect( port, r, ovWd, ovHt )
- SCM_obj port, r, ovWd, ovHt;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- EraseRoundRect( SCM_obj_to_str(r), (int)SCM_obj_to_int(ovWd), (int)SCM_obj_to_int(ovHt) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23invertroundrect( port, r, ovWd, ovHt )
- SCM_obj port, r, ovWd, ovHt;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- InvertRoundRect( SCM_obj_to_str(r), (int)SCM_obj_to_int(ovWd), (int)SCM_obj_to_int(ovHt) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23fillroundrect( port, r, ovWd, ovHt, pat )
- SCM_obj port, r, ovWd, ovHt, pat;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- FillRoundRect( SCM_obj_to_str(r), (int)SCM_obj_to_int(ovWd), (int)SCM_obj_to_int(ovHt), SCM_obj_to_str(pat) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23frameoval( port, r )
- SCM_obj port, r;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- FrameOval( SCM_obj_to_str(r) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23paintoval( port, r )
- SCM_obj port, r;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- PaintOval( SCM_obj_to_str(r) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23eraseoval( port, r )
- SCM_obj port, r;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- EraseOval( SCM_obj_to_str(r) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23invertoval( port, r )
- SCM_obj port, r;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- InvertOval( SCM_obj_to_str(r) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23filloval( port, r, pat )
- SCM_obj port, r, pat;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- FillOval( SCM_obj_to_str(r), SCM_obj_to_str(pat) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23framearc( port, r, startAngle, arcAngle )
- SCM_obj port, r, startAngle, arcAngle;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- FrameArc( SCM_obj_to_str(r),(int)SCM_obj_to_int(startAngle), (int)SCM_obj_to_int(arcAngle) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23paintarc( port, r, startAngle, arcAngle )
- SCM_obj port, r, startAngle, arcAngle;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- PaintArc( SCM_obj_to_str(r),(int)SCM_obj_to_int(startAngle), (int)SCM_obj_to_int(arcAngle) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23erasearc( port, r, startAngle, arcAngle )
- SCM_obj port, r, startAngle, arcAngle;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- EraseArc( SCM_obj_to_str(r),(int)SCM_obj_to_int(startAngle), (int)SCM_obj_to_int(arcAngle) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23invertarc( port, r, startAngle, arcAngle )
- SCM_obj port, r, startAngle, arcAngle;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- InvertArc( SCM_obj_to_str(r),(int)SCM_obj_to_int(startAngle), (int)SCM_obj_to_int(arcAngle) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23fillarc( port, r, startAngle, arcAngle, pat )
- SCM_obj port, r, startAngle, arcAngle, pat;
- { GrafPtr save; GetPort( &save ); SetPort( (GrafPtr)SCM_obj_to_int(port) );
- FillArc( SCM_obj_to_str(r),(int)SCM_obj_to_int(startAngle), (int)SCM_obj_to_int(arcAngle), SCM_obj_to_str(pat) );
- SetPort( save );
- return (long)SCM_false;
- }
-
- /*---------------------------------------------------------------------------*/
-
- /* menus */
-
- SCM_obj mac_X23newmenu( menuid, str )
- SCM_obj menuid, str;
- { MenuHandle mh;
- Str255 pstr;
- pascal_str( str, pstr );
- mh = NewMenu( (int)SCM_obj_to_int(menuid), pstr );
- return (long)SCM_int_to_obj((long)mh);
- }
-
- SCM_obj mac_X23getmenu( resourceid )
- SCM_obj resourceid;
- { MenuHandle mh;
- mh = GetMenu( (int)SCM_obj_to_int(resourceid) );
- return (long)SCM_int_to_obj((long)mh);
- }
-
- SCM_obj mac_X23disposemenu( themenu )
- SCM_obj themenu;
- { DisposeMenu( (MenuHandle)SCM_obj_to_int(themenu) );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23appendmenu( themenu, str )
- SCM_obj themenu, str;
- { Str255 pstr;
- pascal_str( str, pstr );
- AppendMenu( (MenuHandle)SCM_obj_to_int(themenu), pstr );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23addresmenu( themenu, thetype )
- SCM_obj themenu, thetype;
- { AddResMenu( (MenuHandle)SCM_obj_to_int(themenu), *SCM_obj_to_vect(thetype) );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23insertresmenu( themenu, thetype, afteritem )
- SCM_obj themenu, thetype, afteritem;
- { InsertResMenu( (MenuHandle)SCM_obj_to_int(themenu), *SCM_obj_to_vect(thetype), (int)SCM_obj_to_int(afteritem) );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23insertmenu( themenu, beforeid )
- SCM_obj themenu, beforeid;
- { InsertMenu( (MenuHandle)SCM_obj_to_int(themenu), (int)SCM_obj_to_int(beforeid) );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23drawmenubar()
- { DrawMenuBar();
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23deletemenu( menuid )
- SCM_obj menuid;
- { DeleteMenu( (int)SCM_obj_to_int(menuid) );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23clearmenubar()
- { ClearMenuBar();
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23getnewmbar( menubarid )
- SCM_obj menubarid;
- { Handle h;
- h = GetNewMBar( (int)SCM_obj_to_int(menubarid) );
- return (long)SCM_int_to_obj((long)h);
- }
-
- SCM_obj mac_X23getmenubar()
- { Handle h;
- h = GetMenuBar();
- return (long)SCM_int_to_obj((long)h);
- }
-
- SCM_obj mac_X23setmenubar( menulist )
- SCM_obj menulist;
- { SetMenuBar( (Handle)SCM_obj_to_int(menulist) );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23menuselect( p )
- SCM_obj p;
- { Point startpt = *(Point *)SCM_obj_to_str(p);
- long res = MenuSelect( startpt );
- return (long)SCM_int_to_obj(res);
- }
-
- SCM_obj mac_X23menukey( ch )
- SCM_obj ch;
- { long res = MenuKey( (char)SCM_obj_to_int(ch) );
- return (long)SCM_int_to_obj(res);
- }
-
- SCM_obj mac_X23hilitemenu( menuid )
- SCM_obj menuid;
- { HiliteMenu( (int)SCM_obj_to_int(menuid) );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23disableitem( themenu, item )
- SCM_obj themenu, item;
- { DisableItem( (MenuHandle)SCM_obj_to_int(themenu), (int)SCM_obj_to_int(item) );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23enableitem( themenu, item )
- SCM_obj themenu, item;
- { EnableItem( (MenuHandle)SCM_obj_to_int(themenu), (int)SCM_obj_to_int(item) );
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23getmhandle( menuid )
- SCM_obj menuid;
- { MenuHandle mh;
- mh = GetMHandle( (int)SCM_obj_to_int(menuid) );
- return (long)SCM_int_to_obj((long)mh);
- }
-
- /*---------------------------------------------------------------------------*/
-
- /* stdfile */
-
- #if THINK_C < 5
- #include <StdFilePkg.h>
- #endif
-
- extern int getfullpathfromcurrentvolume( /* fName, Path, MaxLength, warn */ );
- extern int get_file( /* prompt, nbtypes, ftypes, path, maxlength */ );
- extern int put_file( /* prompt, deflt, path, maxlength */ );
-
- SCM_obj mac_X23sfgetfile( s, prompt, ftypes ) /* s is a Scheme string which is overwritten */
- SCM_obj s, prompt, ftypes;
- {
- int nbtypes = SCM_length(ftypes) / sizeof(long);
- int maxlength = SCM_length(s);
- char *p = SCM_obj_to_str(prompt);
- long len = SCM_length(prompt);
- Str255 pprompt;
-
- if (len >= 256) return (long)SCM_false;
- pprompt[0] = len;
- while (len > 0) { len--; pprompt[len+1] = p[len]; }
-
- p = SCM_obj_to_str(s);
- if (get_file( pprompt, nbtypes, SCM_obj_to_str(ftypes), p, maxlength ))
- {
- len = 0;
- while (p[len] != '\0') len++;
- *(long *)(s - SCM_type_SUBTYPED) = SCM_make_header( len, SCM_subtype_STRING );
- return s;
- }
- else
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23sfputfile( s, prompt, dflt ) /* s is a Scheme string which is overwritten */
- SCM_obj s, prompt, dflt;
- {
- int maxlength = SCM_length(s);
- char *p = SCM_obj_to_str(prompt);
- long len = SCM_length(prompt);
- Str255 pprompt, pdflt;
-
- if (len >= 256) return (long)SCM_false;
- pprompt[0] = len;
- while (len > 0) { len--; pprompt[len+1] = p[len]; }
-
- p = SCM_obj_to_str(dflt);
- len = SCM_length(dflt);
- if (len >= 256) return (long)SCM_false;
- pdflt[0] = len;
- while (len > 0) { len--; pdflt[len+1] = p[len]; }
-
- p = SCM_obj_to_str(s);
- if (put_file( pprompt, pdflt, p, maxlength ))
- {
- len = 0;
- while (p[len] != '\0') len++;
- *(long *)(s - SCM_type_SUBTYPED) = SCM_make_header( len, SCM_subtype_STRING );
- return s;
- }
- else
- return (long)SCM_false;
- }
-
- /*---------------------------------------------------------------------------*/
-
- SCM_obj mac_X23getmouse( pt )
- SCM_obj pt;
- { GetMouse( SCM_obj_to_str(pt) ); return (long)SCM_false; }
-
- SCM_obj mac_X23button()
- { if (Button()) return (long)SCM_true; else return (long)SCM_false; }
-
- SCM_obj mac_X23tickcount()
- { return SCM_int_to_obj( TickCount() ); }
-
- SCM_obj mac_X23delay( numTicks )
- SCM_obj numTicks;
- { long finalTicks;
- Delay( (long)SCM_obj_to_int(numTicks), &finalTicks );
- return SCM_int_to_obj( finalTicks );
- }
-
- SCM_obj mac_X23sysbeep( duration )
- SCM_obj duration;
- { SysBeep( (int)SCM_obj_to_int(duration) ); return (long)SCM_false; }
-
- SCM_obj mac_X23seteventmask( theMask )
- SCM_obj theMask;
- { SetEventMask( (int)SCM_obj_to_int(theMask) ); return (long)SCM_false; }
-
- SCM_obj mac_X23peek8( ptr )
- SCM_obj ptr;
- { return SCM_int_to_obj( (long)*((unsigned char *)SCM_obj_to_int(ptr)) ); }
-
- SCM_obj mac_X23poke8( ptr, val )
- SCM_obj ptr, val;
- { *((unsigned char *)SCM_obj_to_int(ptr)) = (unsigned char)SCM_obj_to_int(val);
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23peek16( ptr )
- SCM_obj ptr;
- { return SCM_int_to_obj( (long)*((short *)SCM_obj_to_int(ptr)) ); }
-
- SCM_obj mac_X23poke16( ptr, val )
- SCM_obj ptr, val;
- { *((short *)SCM_obj_to_int(ptr)) = (short)SCM_obj_to_int(val);
- return (long)SCM_false;
- }
-
- SCM_obj mac_X23peek32( ptr )
- SCM_obj ptr;
- { return SCM_int_to_obj( (long)*((long *)SCM_obj_to_int(ptr)) ); }
-
- SCM_obj mac_X23poke32( ptr, val )
- SCM_obj ptr, val;
- { *((long *)SCM_obj_to_int(ptr)) = (long)SCM_obj_to_int(val);
- return (long)SCM_false;
- }
-
- extern int edit( /* name, line, chr */ );
-
- SCM_obj mac_X23edit( name, line, chr)
- SCM_obj name, line, chr;
- { SCM_obj result;
- GrafPtr save;
- char pname[FILENAME_LEN];
- char path[FILENAME_LEN];
- char *p = SCM_obj_to_str(name);
- long len = SCM_length(name);
- int full_path = 0;
-
- if ((len == 0) || (len >= FILENAME_LEN)) return (long)SCM_false;
-
- GetPort( &save );
-
- pname[0] = len;
- path[len] = '\0';
- while (len > 0)
- { char c = p[len-1];
- if (c == ':') full_path = 1;
- pname[len] = c;
- len--;
- path[len] = c;
- }
-
- if ((full_path || getfullpathfromcurrentvolume( pname, path, FILENAME_LEN, 1 )) &&
- edit( path, SCM_obj_to_int(line), SCM_obj_to_int(chr) ))
- result = (long)SCM_true;
- else
- result = (long)SCM_false;
-
- SetPort( save );
-
- return result;
- }
-
- SCM_obj mac_X23help( str )
- SCM_obj str;
- { Str255 pstr;
- pascal_str( str, pstr );
- help_find( pstr );
- return (long)SCM_false;
- }
-
- /*---------------------------------------------------------------------------*/
-
-
- void ext_init()
- { DEFINE_C_PROC(mac_X23newwindow);
- DEFINE_C_PROC(mac_X23getnewwindow);
- DEFINE_C_PROC(mac_X23disposewindow);
- DEFINE_C_PROC(mac_X23setwtitle);
- DEFINE_C_PROC(mac_X23selectwindow);
- DEFINE_C_PROC(mac_X23hidewindow);
- DEFINE_C_PROC(mac_X23showwindow);
- DEFINE_C_PROC(mac_X23frontwindow);
- DEFINE_C_PROC(mac_X23findwindow);
- DEFINE_C_PROC(mac_X23trackgoaway);
- DEFINE_C_PROC(mac_X23dragwindow);
- DEFINE_C_PROC(mac_X23invalrect);
- DEFINE_C_PROC(mac_X23beginupdate);
- DEFINE_C_PROC(mac_X23endupdate);
-
- DEFINE_C_PROC(mac_X23openport);
- DEFINE_C_PROC(mac_X23initport);
- DEFINE_C_PROC(mac_X23closeport);
- DEFINE_C_PROC(mac_X23setport);
- DEFINE_C_PROC(mac_X23getport);
- DEFINE_C_PROC(mac_X23setorigin);
- DEFINE_C_PROC(mac_X23backpat);
- DEFINE_C_PROC(mac_X23hidecursor);
- DEFINE_C_PROC(mac_X23showcursor);
- DEFINE_C_PROC(mac_X23pensize);
- DEFINE_C_PROC(mac_X23penmode);
- DEFINE_C_PROC(mac_X23penpat);
- DEFINE_C_PROC(mac_X23pennormal);
- DEFINE_C_PROC(mac_X23moveto);
- DEFINE_C_PROC(mac_X23move);
- DEFINE_C_PROC(mac_X23lineto);
- DEFINE_C_PROC(mac_X23line);
- DEFINE_C_PROC(mac_X23textfont);
- DEFINE_C_PROC(mac_X23textface);
- DEFINE_C_PROC(mac_X23textmode);
- DEFINE_C_PROC(mac_X23textsize);
- DEFINE_C_PROC(mac_X23spaceextra);
- DEFINE_C_PROC(mac_X23drawchar);
- DEFINE_C_PROC(mac_X23drawstring);
- DEFINE_C_PROC(mac_X23drawtext);
- DEFINE_C_PROC(mac_X23charwidth);
- DEFINE_C_PROC(mac_X23stringwidth);
- DEFINE_C_PROC(mac_X23textwidth);
- DEFINE_C_PROC(mac_X23localtoglobal);
- DEFINE_C_PROC(mac_X23globaltolocal);
- DEFINE_C_PROC(mac_X23framerect);
- DEFINE_C_PROC(mac_X23paintrect);
- DEFINE_C_PROC(mac_X23eraserect);
- DEFINE_C_PROC(mac_X23invertrect);
- DEFINE_C_PROC(mac_X23fillrect);
- DEFINE_C_PROC(mac_X23frameroundrect);
- DEFINE_C_PROC(mac_X23paintroundrect);
- DEFINE_C_PROC(mac_X23eraseroundrect);
- DEFINE_C_PROC(mac_X23invertroundrect);
- DEFINE_C_PROC(mac_X23fillroundrect);
- DEFINE_C_PROC(mac_X23frameoval);
- DEFINE_C_PROC(mac_X23paintoval);
- DEFINE_C_PROC(mac_X23eraseoval);
- DEFINE_C_PROC(mac_X23invertoval);
- DEFINE_C_PROC(mac_X23filloval);
- DEFINE_C_PROC(mac_X23framearc);
- DEFINE_C_PROC(mac_X23paintarc);
- DEFINE_C_PROC(mac_X23erasearc);
- DEFINE_C_PROC(mac_X23invertarc);
- DEFINE_C_PROC(mac_X23fillarc);
-
- DEFINE_C_PROC(mac_X23newmenu);
- DEFINE_C_PROC(mac_X23getmenu);
- DEFINE_C_PROC(mac_X23disposemenu);
- DEFINE_C_PROC(mac_X23appendmenu);
- DEFINE_C_PROC(mac_X23addresmenu);
- DEFINE_C_PROC(mac_X23insertresmenu);
- DEFINE_C_PROC(mac_X23insertmenu);
- DEFINE_C_PROC(mac_X23drawmenubar);
- DEFINE_C_PROC(mac_X23deletemenu);
- DEFINE_C_PROC(mac_X23clearmenubar);
- DEFINE_C_PROC(mac_X23getnewmbar);
- DEFINE_C_PROC(mac_X23getmenubar);
- DEFINE_C_PROC(mac_X23setmenubar);
- DEFINE_C_PROC(mac_X23menuselect);
- DEFINE_C_PROC(mac_X23menukey);
- DEFINE_C_PROC(mac_X23hilitemenu);
- DEFINE_C_PROC(mac_X23disableitem);
- DEFINE_C_PROC(mac_X23enableitem);
- DEFINE_C_PROC(mac_X23getmhandle);
-
- DEFINE_C_PROC(mac_X23sfgetfile);
- DEFINE_C_PROC(mac_X23sfputfile);
-
- DEFINE_C_PROC(mac_X23getmouse);
- DEFINE_C_PROC(mac_X23button);
- DEFINE_C_PROC(mac_X23tickcount);
- DEFINE_C_PROC(mac_X23delay);
- DEFINE_C_PROC(mac_X23sysbeep);
- DEFINE_C_PROC(mac_X23seteventmask);
-
- DEFINE_C_PROC(mac_X23peek8);
- DEFINE_C_PROC(mac_X23poke8);
- DEFINE_C_PROC(mac_X23peek16);
- DEFINE_C_PROC(mac_X23poke16);
- DEFINE_C_PROC(mac_X23peek32);
- DEFINE_C_PROC(mac_X23poke32);
-
- DEFINE_C_PROC(mac_X23edit);
- DEFINE_C_PROC(mac_X23help);
- }
-
-
- /*---------------------------------------------------------------------------*/
-